public class Demo21 {
    public static void main(String[] args){
        String fruit = "apple";
        int opt = switch (fruit){
            case "apple" -> 1;
            case "pear", "mango" -> 2;
            default -> 0;
        };
        System.out.println("opt="+opt);
    }
}
